<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<!--标准mui.css-->
		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../css/style.css">
		<style>
			body{
				background: #fff!important;
			}
			.mui-icon{
				font-family: Muiicons!important;
			}
			h5 {
				margin: 5px 7px;
			}
			.mui-action-back:before{
				content: "\e582"!important;
			}
			.mui-action-back{
				color:#fff;
			}
			.mui-btn.mui-btn-link{
				color:#fff; 
			}
			.inputName{
				border:none!important;
				border-bottom:solid 1px #ccc!important;
				background:none!important;
				border-radius:none!important;
				width:4rem!important; 
				height:20px!important;
				margin: 0!important;
				padding: 0!important;
			}
			.passwordBox span{
				font-size: 12px!important;
				float: left;
				width: 2.5rem;
				text-align: right;
				padding-right: 0.2rem;
			}
			.mui-password {
				padding: 0 0.5rem;
				padding-top: 0.2rem;
				
			}
			.mui-password li{
				margin-bottom: 0.2rem;
			}
			#password{
				border:solid 1px #e1e1e1!important;
				width: 100%!important;
				border-radius: 5px;
				height: 40px!important;
				padding-left: 10px!important;
			}
			#passwordagain{
				border:solid 1px #e1e1e1!important;
				width: 100%!important;
				border-radius: 5px;
				height: 40px!important;
				padding-left: 10px!important;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" style="background-color: #fff;">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: #000;"></a>
				<h1 class="mui-title" style="color:#000;"><span id="typeName">修改密码</span></h1>
			<a class="mui-btn mui-btn-link mui-pull-right" id="savebtn" style="color: #000;">保存</a>
		</header>
		<div class="passwordBox mui-content">
			<div class="mui-content-padded me_content_list" style="margin:0px;">
				<div class="mui-input-row mui-password">
					<ul>
						<li>
							<input class="inputName" id="password" autofocus="autofocus" type="password" placeholder="请输入新密码">
						</li>
						<li>
							<input class="inputName" id="passwordagain" autofocus="autofocus" type="password" class="mui-input-text" placeholder="请再次输入新密码">
						</li>
					</ul>
				</div>
			</div>
		</div>
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/vue.min.js"></script>
		<script src="../../../js/app.js"></script>
		<script src="../../../js/token.js"></script>
		<script src="../../../js/jquery-1.8.3.min.js"></script>	
		<script>
			mui.init({
				swipeBack: true //启用右滑关闭功能
			});

			var nativeWebview, imm, InputMethodManager;
			var initNativeObjects = function() {
				if (mui.os.android) { 
					var main = plus.android.runtimeMainActivity();
					var Context = plus.android.importClass("android.content.Context");
					InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
					imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
				} else {
					nativeWebview = plus.webview.currentWebview().nativeInstanceObject();
				}
			};
			var showSoftInput = function() {
				if (mui.os.android) {
					imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
				} else {
					nativeWebview.plusCallMethod({
						"setKeyboardDisplayRequiresUserAction": false
					});
				}
				setTimeout(function() {
					var inputElem = document.querySelector('input');
					inputElem.focus();
					inputElem.parentNode.classList.add('mui-active'); //第一个是search，加上激活样式
				}, 200);
			};
			var uid='';
			var state='';
			mui.plusReady(function() {
				var self=plus.webview.currentWebview();
				state=app.getState();
				memberToken = state.memberToken;
				uid=state.userid;
				type=self.type;
				
				setTimeout(function() {
				initNativeObjects();
				showSoftInput();
				},50)
			});
			var password = document.getElementById('password');
			var passwordagain = document.getElementById('passwordagain');
			document.getElementById('savebtn').addEventListener('tap',function(){
						if(password!=passwordagain){
							plus.nativeUI.toast('您两次输入的密码不一致', {
								verticalAlign: 'middle'
							});
						}else{
							mui.post(Apiurl+'index/member_info',{ 
								uid:uid,
								pwd:password.value,
								memberToken: memberToken
							},function(data){
								if(data.status==200){
									plus.nativeUI.toast('修改成功', {
										verticalAlign: 'middle'
									});
									plus.webview.currentWebview().close();
								}else if(data.status==201){
									plus.nativeUI.toast('新密码不能与旧密码相同', {
										verticalAlign: 'middle'
									});
								}
							},'json')
						}
						
			})
			
		</script>
	</body>

</html>